package com.ansuenjob.util;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;

public final class StreamTool {
   
	public static byte[] readDataFromStream(InputStream inputStream) throws IOException{
		byte[] buffer = new byte[1024];
		ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
		int len = -1;
		while((len=inputStream.read(buffer)) != -1){
			outputStream.write(buffer, 0, len);
		}
		byte data[] =  outputStream.toByteArray();
		outputStream.flush();
		outputStream.close();
		
		return data;
	}
}
